﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BDS3M.Admin.Controls
{
    public partial class ListCategoryImage : System.Web.UI.UserControl
    {
        public int count;
        protected void Page_Load(object sender, EventArgs e)
        {

            count = 1;
            rpt_banner.DataSource = DAL.DCollector.DBCollector.Instance.StoredSelectAllTable("tbl_CategoryAnh");

            rpt_banner.DataBind();

        }

        protected void rpt_banner_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "delete")
            {
                int id = Convert.ToInt32(e.CommandArgument.ToString());
                DataTable dt = DAL.DCollector.DBCollector.Instance.StoredProcedureSelectWhereByID("tbl_ThuVienAnh", "*", "CategoryAnh_ID", id, "selectwhereid");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DAL.DCollector.DBCollector.Instance.StoredProcedureDeleteByRows("tbl_ThuVienAnh", "ThuVienAnh_ID",dt.Rows[i]["ThuVienAnh_ID"].ToString() );
                }
                DAL.DCollector.DBCollector.Instance.StoredProcedureDeleteByRows("tbl_CategoryAnh", "CategoryAnh_ID", id.ToString());
                Response.Redirect("/Admin/Index.aspx?panel=5&sub=9");
            }
        }
    }
}